/*    */ package com.zimbra.cs.lmtpserver;
/*    */ 
/*    */ import com.zimbra.common.io.TcpServerInputStream;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.NetUtil;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import java.io.IOException;
/*    */ import java.net.InetAddress;
/*    */ import java.net.Socket;
/*    */ import javax.net.ssl.SSLSocket;
/*    */ import javax.net.ssl.SSLSocketFactory;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class TcpLmtpHandler
/*    */   extends LmtpHandler
/*    */ {
/*    */   private TcpServerInputStream inputStream;
/*    */   
/*    */   TcpLmtpHandler(LmtpServer server)
/*    */   {
/* 34 */     super(server);
/*    */   }
/*    */   
/*    */   protected boolean setupConnection(Socket connection) throws IOException
/*    */   {
/* 39 */     reset();
/* 40 */     this.inputStream = new TcpServerInputStream(connection.getInputStream());
/* 41 */     this.mWriter = new LmtpWriter(connection.getOutputStream());
/* 42 */     return setupConnection(connection.getInetAddress());
/*    */   }
/*    */   
/*    */   protected synchronized void dropConnection()
/*    */   {
/* 47 */     ZimbraLog.addIpToContext(this.mRemoteAddress);
/*    */     try {
/* 49 */       if (this.inputStream != null) {
/* 50 */         this.inputStream.close();
/* 51 */         this.inputStream = null;
/*    */       }
/* 53 */       if (this.mWriter != null) {
/* 54 */         this.mWriter.close();
/* 55 */         this.mWriter = null;
/*    */       }
/*    */     } catch (IOException e) {
/* 58 */       if (ZimbraLog.lmtp.isDebugEnabled()) {
/* 59 */         ZimbraLog.lmtp.info("I/O error while closing connection", e);
/*    */       } else {
/* 61 */         ZimbraLog.lmtp.info("I/O error while closing connection: " + e);
/*    */       }
/*    */     } finally {
/* 64 */       ZimbraLog.clearContext();
/*    */     }
/*    */   }
/*    */   
/*    */   protected boolean processCommand()
/*    */     throws IOException
/*    */   {
/* 71 */     if (this.inputStream != null)
/* 72 */       return processCommand(this.inputStream.readLine());
/* 73 */     return false;
/*    */   }
/*    */   
/*    */   protected void continueDATA() throws IOException
/*    */   {
/* 78 */     LmtpMessageInputStream min = new LmtpMessageInputStream(this.inputStream, getAdditionalHeaders());
/* 79 */     processMessageData(min);
/*    */   }
/*    */   
/*    */   protected void doSTARTTLS(String arg) throws IOException
/*    */   {
/* 84 */     if (arg != null) {
/* 85 */       sendReply(LmtpReply.STARTTLS_WITH_PARAMETER);
/* 86 */       return;
/*    */     }
/* 88 */     sendReply(LmtpReply.READY_TO_START_TLS);
/* 89 */     SSLSocketFactory fac = (SSLSocketFactory)SSLSocketFactory.getDefault();
/* 90 */     SSLSocket tlsconn = (SSLSocket)fac.createSocket(this.connection, this.connection.getInetAddress().getHostName(), this.connection.getPort(), true);
/*    */     
/* 92 */     NetUtil.setSSLEnabledCipherSuites(tlsconn, this.config.getSslExcludedCiphers(), this.config.getSslIncludedCiphers());
/* 93 */     tlsconn.setUseClientMode(false);
/* 94 */     startHandshake(tlsconn);
/* 95 */     this.inputStream = new TcpServerInputStream(tlsconn.getInputStream());
/* 96 */     this.mWriter = new LmtpWriter(tlsconn.getOutputStream());
/* 97 */     this.startedTLS = true;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/lmtpserver/TcpLmtpHandler.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */